package com.workstudy.workstudy.service.impl;

import java.util.List;

import com.workstudy.workstudy.domain.WorkstudyPost;
import com.workstudy.workstudy.mapper.WorkstudyPostMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.workstudy.workstudy.mapper.WorkstudyPostUserMapper;
import com.workstudy.workstudy.domain.WorkstudyPostUser;
import com.workstudy.workstudy.service.IWorkstudyPostUserService;
import com.workstudy.common.core.text.Convert;

/**
 * 学生申请岗位Service业务层处理
 * 
 * @author ws
 * @date 2021-03-28
 */
@Service
public class WorkstudyPostUserServiceImpl implements IWorkstudyPostUserService 
{
    @Autowired
    private WorkstudyPostUserMapper workstudyPostUserMapper;

    @Autowired
    private WorkstudyPostMapper workstudyPostMapper;

    /**
     * 查询学生申请岗位
     * 
     * @param postUserId 学生申请岗位ID
     * @return 学生申请岗位
     */
    @Override
    public WorkstudyPostUser selectWorkstudyPostUserById(Long postUserId)
    {
        return workstudyPostUserMapper.selectWorkstudyPostUserById(postUserId);
    }

    /**
     * 查询学生申请岗位列表
     * 
     * @param workstudyPostUser 学生申请岗位
     * @return 学生申请岗位
     */
    @Override
    public List<WorkstudyPostUser> selectWorkstudyPostUserList(WorkstudyPostUser workstudyPostUser)
    {
        return workstudyPostUserMapper.selectWorkstudyPostUserList(workstudyPostUser);
    }

    /**
     * 新增学生申请岗位
     * 
     * @param workstudyPostUser 学生申请岗位
     * @return 结果
     */
    @Override
    public int insertWorkstudyPostUser(WorkstudyPostUser workstudyPostUser)
    {
        //设置用人单位
        WorkstudyPost workstudyPost = workstudyPostMapper.selectWorkstudyPostById(workstudyPostUser.getPostId());
        workstudyPostUser.setApproveEndBy(workstudyPost.getAnnouncerBy());
        return workstudyPostUserMapper.insertWorkstudyPostUser(workstudyPostUser);
    }

    /**
     * 修改学生申请岗位
     * 
     * @param workstudyPostUser 学生申请岗位
     * @return 结果
     */
    @Override
    public int updateWorkstudyPostUser(WorkstudyPostUser workstudyPostUser)
    {
        return workstudyPostUserMapper.updateWorkstudyPostUser(workstudyPostUser);
    }

    /**
     * 删除学生申请岗位对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWorkstudyPostUserByIds(String ids)
    {
        return workstudyPostUserMapper.deleteWorkstudyPostUserByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除学生申请岗位信息
     * 
     * @param postUserId 学生申请岗位ID
     * @return 结果
     */
    @Override
    public int deleteWorkstudyPostUserById(Long postUserId)
    {
        return workstudyPostUserMapper.deleteWorkstudyPostUserById(postUserId);
    }

    @Override
    public int updateWorkstudyPostUserAppr(WorkstudyPostUser workstudyPostUser) {
        return workstudyPostUserMapper.updateWorkstudyPostUserAppr(workstudyPostUser);
    }

    @Override
    public int updateWorkstudyPostUserAppr2(WorkstudyPostUser workstudyPostUser) {
        return workstudyPostUserMapper.updateWorkstudyPostUserAppr2(workstudyPostUser);
    }

    @Override
    public int selectWorkstudyPostUserBycount(WorkstudyPostUser workstudyPostUser) {
        return workstudyPostUserMapper.selectWorkstudyPostUserBycount(workstudyPostUser);
    }
}
